import java.util.Random;


/**
 * @author Benjamin Zwanzger
 * @version v1.0
 * @date 27.03.2013
 * 
 */

public class Password {

	
	/**
	 * Generate passwords.
	 *
	 * @param n the n
	 * @param length the length
	 * @return the string[]
	 */
	public String[] generatePasswords(int n, int length) {//n: amount of passwords
		String[] passwords = new String[n];
		Random random = new Random();
		for (int i = 0; i < n; i++) {
			passwords[i] = generatePassword(length, random);
			System.out.println(passwords[i]);
		}
		return passwords;
	}
	
	/**
	 * Generate a single Password
	 *
	 * @param length the length
	 * @param random the random
	 * @return the string
	 */
	public String generatePassword(int length, Random random) {
		StringBuilder builder = new StringBuilder(length);//builder with (int capacity)
		for (int i = 0; i < length; i++) {
			builder.append(getRandomChar(random));
		}
		return builder.toString();
	}

	
	/**
	 * Gets the random char.
	 *
	 * @param random the random
	 * @return the random char
	 */
	public char getRandomChar(Random random){
		int lowerChar = 97 + random.nextInt(26); //from ascii, 97 = offset to lower 'a'
		return (char)lowerChar;
	}
	
}
